#include "ejdes.h"

#include <QSplitter>
#include <QTextEdit>
#include <QTextCodec>

#include <QPushButton>
#include <QListWidget>

#include <GL/glew.h>
#include <GL/wglew.h>


EjDes::EjDes(QWidget *parent) : QMainWindow(parent)
{
    //分割窗口
    auto mainSplitter = new QSplitter(Qt::Horizontal, this);
    auto leftEdit     = new QTextEdit(QObject::tr("左窗口"), mainSplitter);
    leftEdit->setAlignment(Qt::AlignCenter);

    //创建右分割窗口
    auto rightSplitter= new QSplitter(Qt::Vertical, mainSplitter);
    //设定分割窗口的分割条在拖动时是否为实时更新 true为实时更新 false则在拖动时只显示一条灰色的线条
    //在拖动到位并弹起鼠标后再显示分隔条
    rightSplitter->setOpaqueResize(false);
    //开始将其分割成上下两个窗口
    QTextEdit *upEdit = new QTextEdit(QObject::tr("上窗口"), rightSplitter);
    upEdit->setAlignment(Qt::AlignCenter);
    QTextEdit *bottomEdit = new QTextEdit(QObject::tr("下窗口"), rightSplitter);
    bottomEdit->setAlignment(Qt::AlignCenter);
    //设定可伸缩控件 第一个参数指定控件设置的控件序号，该控件序号按插入的先后次序依次从0开始编号
    //第二个参数大于0表示此控件为伸缩控件 此例中设置右部分割窗口为可伸缩控件
    mainSplitter->setStretchFactor(0, 1);
    setCentralWidget(mainSplitter);


    HDC hDC = wglGetCurrentDC();
    //hRC = wglGetCurrentContext();

    HGLRC glrc = wglCreateContext(hDC);

    if (glrc == 0) {
        exit(1);
    }

    wglMakeCurrent(hDC, glrc);

    if ( glewInit() != GLEW_OK )
    {
        exit(1);
    }

    glViewport(0, 0, leftEdit->geometry().width(), leftEdit->geometry().height());

}
